Glitch Methods
===============
This page contains the documentation for 'Glitch_Methods.py'. This module contains functions for generating short transient glitches.
Function Definitions
----------------------
.. raw:: html
GlitchPop.Glitch_Methods.psd_glitch(ifo, run, low_frequency_cutoff = 0)
Generates PSD for colouring glitches. PSDs are from PyCBC's analytical PSD module.
**Parameters:**
- **ifo** (string) - Interferometer abbreviation
- **run** (string) - Observing run
- **low_frequency_cutoff** (float) - Low frequency cutoff for filtering
**Returns:**
- **pycbc.types.frequencyseries.FrequencySeries** - Power spectral density to colour glitch spectra
.. raw:: html
GlitchPop.Glitch_Methods.rounder(number, rate = 1/4096)
Rounds to multiple of sampling rate. Used for avoiding errors when functions are given times that are not multiples of the sampling rate.
**Parameters:**
- **number** (float) - Value to round
- **rate** (float) - Sampling rate; rounds to nearest multiple of this number
**Returns:**
- **float** - Value rounded to multiple of the given rate
.. raw:: html
GlitchPop.Glitch_Methods.noise(duration, ifo, run, seed = None, scale = 1)
Generates coloured noise based on a real PSD. Noise is based off of both the detector and the given observing run.
**Parameters:**
- **duration** (float) - Duration of noise in seconds
- **ifo** (string) - Interferometer abbreviation
- **run** (string) - Observing run
- **seed** (Nonetype or int) - Optional random seed
- **scale** (float) - Scale of gaussian noise
**Returns:**
- **pycbc.types.timeseries.TimeSeries** - Time series containing coloured gaussian noise
.. raw:: html
GlitchPop.Glitch_Methods.center(data)
Shifts data from the start to the center of a time series. Used in centering the initial 1/16 second long glitch signals.
**Parameters:**
- **data** (np.array) - Array of data to center
**Returns:**
- **np.array** - Centered data array
.. raw:: html
GlitchPop.Glitch_Methods.fsignal(freqs, f0, gbw)
Calculates the frequency signal for a given set of parameters.
**Parameters:**
- **freqs** (np.array) - Array of frequencies
- **f0** (float) - Central frequency
- **gbw** (float) - Gamma or inverse bandwidth squared
**Returns:**
- **jnp.array** - Frequency signal based on the input parameters
.. raw:: html
GlitchPop.Glitch_Methods.glitch_fd(amp, phase, f0, gbw, psd, *kwargs)
Generates a coloured glitch in the complex frequency domain.
**Parameters:**
- **amp** (float) - Amplitude of glitch
- **phase** (float) - Phase of glitch
- **f0** (float) - Central frequency of glitch
- **gbw** (float) - 'Gamma' or inverse bandwidth squared of glitch
- **psd** (pycbc.types.frequencyseries.FrequencySeries) - PSD to colour glitch
**Returns:**
- **jaxlib.xla_extension.ArrayImpl** - Complex spectrum of glitch
.. raw:: html
GlitchPop.Glitch_Methods.glitch_td(amp, phase, f0, gbw, psd, **kwargs)
Generates coloured and windowed glitch time series centered around zero.
**Parameters:**
- **amp** (float) - Amplitude of glitch
- **phase** (float) - Phase of glitch
- **f0** (float) - Central frequency of glitch
- **gbw** (float) - 'Gamma' or inverse bandwidth squared of glitch
- **psd** (pycbc.types.frequencyseries.FrequencySeries) - PSD to colour glitch
**Returns:**
- **np.array** - 1/16 second long time series containing centered and windowed glitch
.. raw:: html
GlitchPop.Glitch_Methods.td_ext(ifo, run, params, duration, noise, gps = 0, indexes = [], *kwargs)
Generates a time series with arbitrary length and number of glitches with coloured, Gaussian noise.
**Parameters:**
- **ifo** (string) - Interferometer abbreviation
- **run** (string) - Observing run
- **params** (list) - Nested list of glitch parameters [[amplitude, phase, central_freq, gbw], ...]
- **duration** (float) - Duration of noise in seconds
- **noise** (np.array) - Time series of same duration containing coloured gaussian noise
- **gps** (float) - Starting GPS time of time series
- **indexes** (list) - Indexes of which parameters correspond to blips (blips get coloured with different PSDs)
**Returns:**
- **gwpy.timeseries.TimeSeries** - h(t) with gaussian noise and glitches
.. raw:: html
GlitchPop.Glitch_Methods.get_glitch(time, probs = [0.25, 0.25, 0.25, 0.25])
Randomly generates glitch and parameters given central glitch time.
**Parameters:**
- **time** (float) - Central time of glitch
- **probs** (list) - List of probabilities of each type of glitch occurring (sum to one)
**Returns:**
- **list** - List containing glitch parameters
- **string** - Type of glitch generated
.. raw:: html
GlitchPop.Glitch_Methods.glitch_location(mu = 0.1, duration = 100, interval = None)
Generates number and location of glitches with Poissonian distribution.
**Parameters:**
- **mu** (float) - Poisson rate parameter; average number of glitches per second
- **duration** (float) - Duration of time series
- **interval** (NoneType or float) - Optional interval of repeating glitches
**Returns:**
- **np.array** - Central times of each glitch
.. raw:: html
GlitchPop.Glitch_Methods.determ_get_glitch(glitch, time, suggest = True, seed = 0)
Randomly generates glitch parameters with seed. This is used in deterministic generations.
**Parameters:**
- **glitch** (string) - Name of short transient glitch
- **time** (float) - Central time of glitch
- **suggest** (bool) - Option to use suggested bounds on parameter distributions
- **seed** (int) - Random seed
**Returns:**
- **list** - list containing glitch parameters
- **float** - value rounded to multiple of given rate